getenv("CONTENT_LENGTH") 放的是什么

来源:百度知道 编辑:UC知道 时间:2024/06/14 13:19:37
用C语言编写CGI:用GET方法已经实现了,对表单数据的接收和处理;但用POST方法后,我将表单改为<form method="post" action=...>;程序里的buf=getenv("QUERY_STRING")改为buf=getenv("CONTENT_LENGTH");下面什么都不做,只输出buf的内容也无法显示结果出来。怎么修改好呢?我的程序如下:#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
char *buf;
char name[20],number[20],input[20];
int n;
printf("Content-Type:text\n\n");
printf("<html><body>");
printf("<title>表单</title>");
printf("</head><body bgcolor=\"#ffffff\">");
printf("<h3 align=\"center\">");
printf("写一个具有表单的cgi页面,点击递交后,可以转到另外一个页面并显示原表单各项内容</h3>");
printf("<hr color=\"#ff8000\">");

if(getenv("CONTENT_LENGTH"))
n= atoi(getenv(&quo

http://tools.ietf.org/html/rfc2616#section-14.13

14.13 Content-Length

The Content-Length entity-header field indicates the size of the
entity-body, in decimal number of OCTETs, sent to the recipient or,
in the case of the HEAD method, the size of the entity-body that
would have been sent had the request been a GET.

Content-Length = "Content-Length" ":" 1*DIGIT

An example is

Content-Length: 3495

Applications SHOULD use this field to indicate the transfer-length of
the message-body, unless this is prohibited by the rules in section
4.4.

主要就是你数出网页的byte数
相关网页
http://www.wangchao.net.cn/bbsdetail_73981.html